/**
 * 
 */
package org.jenkon.core.filter;

import java.util.zip.ZipEntry;

import org.jenkon.commons.lang.filter.Filter;

/**
 * @author Jens Konopka
 * 
 */
public class JarPackageNameFilter implements Filter<ZipEntry> {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8404421225774419650L;

	private final String path;

	/**
	 * @param packageName the name of the package
	 */
	public JarPackageNameFilter(final String packageName) {
		this.path = getPath(packageName);
	}

	private static String getPath(final String packageName) {
		return packageName.replace(".", "/");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.jenkon.commons.filter.Filter#accept(java.lang.Object)
	 */
	@Override
	public boolean accept(final ZipEntry zipEntry) {
		final String entryName = zipEntry.getName();
		return entryName.startsWith(path);
	}

}
